package com.gaogzhen.designPattern.producerConsumer.fullTextSearch;


import java.util.concurrent.BlockingQueue;

/**
 * @author Administrator
 * @version 1.0
 * @description 基于阻塞队列的通道
 * @date 2022-10-26 09:23
 */
public class BlockingQueueChannel<D> implements Channel<D> {

    private final BlockingQueue<D> queue;

    public BlockingQueueChannel(BlockingQueue<D> queue) {
        this.queue = queue;
    }


    @Override
    public void put(D data) throws InterruptedException {
        queue.put(data);
    }

    @Override
    public D take() throws InterruptedException {
        return queue.take();
    }
}
